//
//  UIAlertController+Lc.h
//  18Birdies
//
//  Created by poleness on 16/6/27.
//  Copyright © 2016年 Lc. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "UIAlertController+Blocks.h"

typedef void (^AlertHandle)(void);
typedef void (^LCAlertHandler)(NSInteger btnIndex);
typedef void (^AlertCompleteHandler)(UIAlertAction* action, NSInteger buttonIndex);

static NSInteger const UIAlertActionCancel = 0;
static NSInteger const UIAlertActionDestructive = -1;
static NSInteger const UIAlertActionFirstOther = 1;

@interface UIAlertController (Lc)

+ (instancetype)alertForNoticeWithTitle:(NSString*)title;
+ (instancetype)alertForNoticeWithTitle:(NSString*)title
                          okAlertHandle:(AlertHandle)okAlertHandle;
+ (instancetype)alertForNoticeWithTitle:(NSString*)title
                                message:(NSString*)message
                          okAlertHandle:(AlertHandle)okAlertHandle
                           cancelHandle:(AlertHandle)cancelAlertHandle;
+ (instancetype)alertForNoticeWithTitle:(NSString*)title
                                message:(NSString*)message
                               okButton:(NSString*)okButton
                           cancelButton:(NSString*)cancelButton
                          okAlertHandle:(AlertHandle)okAlertHandle
                           cancelHandle:(AlertHandle)cancelAlertHandle;

#pragma mark - ActionSheet
/**
 Show the action sheet in the current controller specified by title.
 
 @param title 					The title to show in the action sheet.
 @param btnsArray 					The buttons to show in the action sheet, the order of buttons is from left to right. btns MUST is array of string. The index of button will equal the sort of array.
 @param handler 				A LCAlertHandler block, it will return the index of button by user clicked. "Cancel Button" will always return zero.
 */
+ (void)showActionSheet:(NSString *)title
                   btns:(NSArray *)btnsArray
                handler:(AlertCompleteHandler)handler;

/**
 Show the action sheet in the current controller specified by title.

 @param title 					The title to show in the action sheet.
 @param cancelBtnTitle         The title of cancel button to show in the action sheet.
 @param btnsArray 					The buttons to show in the action sheet, the order of buttons is from left to right. btns MUST is array of string. The index of button will equal the sort of array.
 @param handler 				A LCAlertHandler block, it will return the index of button by user clicked. "Cancel Button" will always return zero.
*/
+ (void)showActionSheet:(NSString *)title
         cancelBtnTitle:(NSString *)cancelBtnTitle
                   btns:(NSArray *)btnsArray
                handler:(AlertCompleteHandler)handler;

/**
 Show the action sheet in the current controller specified by title.
 
 @param title 					The title to show in the action sheet.
 @param msg 					The msg to show in the action sheet.
 @param cancelBtnTitle         The title of cancel button to show in the action sheet.
 @param btnsArray 					The buttons to show in the action sheet, the order of buttons is from left to right. btns MUST is array of string. The index of button will equal the sort of array.
 @param handler 				A LCAlertHandler block, it will return the index of button by user clicked. "Cancel Button" will always return zero.
 */
+ (void)showActionSheet:(NSString *)title
                    msg:(NSString *)msg
         cancelBtnTitle:(NSString *)cancelBtnTitle
                   btns:(NSArray *)btnsArray
                handler:(AlertCompleteHandler)handler;

+ (void)showActionSheet:(NSString *)title
                    msg:(NSString *)msg
         cancelBtnTitle:(NSString *)cancelBtnTitle
        destructivTitle:(NSString *)destructivTitle
                   btns:(NSArray *)btnsArray
                handler:(AlertCompleteHandler)handler;


#pragma mark - Alert
/**
 Show the alert view in the current controller specified by title.
 
 @param title 					The title to show in the alert view.
 */
+ (void)showAlert:(NSString *)title;

/**
 Show the alert view in the current controller specified by msg.
 
 @param msg 					The msg to show in the alert view.
 */
+ (void)showAlertWithMsg:(NSString *)msg;

/**
 Show the alert view in the current controller specified by msg and title.
 
 @param msg 					The msg to show in the alert view.
 @param title 					The title to show in the alert view.
 */
+ (void)showAlert:(NSString *)title msg:(NSString*)msg;

/**
 Show the alert view in the current controller specified by msg & title & cancelBtnTitle.
 
 @param title 					The title to show in the alert view.
 @param msg 					The msg to show in the alert view.
 @param cancelBtnTitle         The title of cancel button to show in the alert view.
 */
+ (void)showAlert:(NSString *)title msg:(NSString*)msg cancelBtnTitle:(NSString*)cancelBtnTitle;

/**
 Show the alert view in the current controller specified by msg and title, handler method specified by a given LCAlertHandler block.
 
 @param title 					The title to show in the alert view.
 @param msg 					The msg to show in the alert view.
 @param handler 				A LCAlertHandler block, it will return the index of button by user clicked. This function will return zero.
 */
+ (void)showAlert:(NSString *)title msg:(NSString *)msg tapBlock:(AlertCompleteHandler)handler;

/**
 Show the alert view in the current controller specified by title & msg & buttons array, actionHandler method specified by a given LCAlertHandler block
 
 @param title 					The title to show in the alert view.
 @param msg 					The msg to show in the alert view.
 @param cancelBtnTitle         The title of cancel button to show in the alert view.
 @param btnsArray 					The buttons to show in the alert view, the order of buttons is from left to right. btns MUST is array of string. The index of button will equal the sort of array.
 @param handler 				A LCAlertHandler block, it will return the index of button by user clicked. "Cancel Button" will always return zero.
 */
+ (void)showAlert:(NSString *)title
              msg:(NSString *)msg
   cancelBtnTitle:(NSString *)cancelBtnTitle
             btns:(NSArray *)btnsArray
         tapBlock:(AlertCompleteHandler)handler;

@end
